home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / epsfig / epsbb < prev    next >
Text File  |  1994-01-26  |  2KB  |  69 lines

  1. #!/usr/local/bin/perl
  2. #
  3. # Extract Bounding Box *.bb and compress postscript figure files.
  4. #
  5. # usage: epsbb          --- For all files in the current directory.
  6. #        epsbb DIR      --- For all files in the directory DIR.
  7. #        epsbb FILES... --- For all the FILES on the command line
  8. #
  9. #  Author: Peter Whaite (peta@mcrcim.mcgill.edu)
  10. #          Centre for Intelligent Machines, McGill University.
  11. $RCSVERSION='$Id: epsbb,v 1.2 1993/09/05 20:16:45 peta Exp $';
  12.  
  13. ## USER CONFIG -- edit the following to suit your system.
  14. #
  15. $GZIP='/usr/local/bin/gzip';
  16. $ZCAT='/usr/local/bin/gunzip -c';
  17. #
  18. ## END USER CONFIG
  19.  
  20. @ARGV=<*> unless ($#ARGV>=0);                        # epsbb
  21. @ARGV=<$ARGV[0]/*> if ($#ARGV==0 && (-d $ARGV[0])); # epsbb DIR
  22.  
  23. FILE: while ($_=shift)
  24. {
  25.     /\.bb$/ && next;
  26.     -e ($eps=$_) || -e ($eps="$_.gz") || -e ($eps="$_.z") || -e ($eps="$_.Z")
  27.     || do { warn("$_ does not exist\n"); next;};
  28.     -f $eps || do { warn("$eps not a plain file\n"); next;};
  29.     $epsf = $eps;
  30.     $compressed = 0;
  31.     $eps =~ /^(.*)\.(gz|z|Z)$/ && do
  32.     {
  33.     $eps = $1;
  34.     $epsf = "$ZCAT $eps|";
  35.     $compressed = 1;
  36.     };
  37.     
  38.     open(EPS,$epsf) || do {warn("$0: $epsf: $!\n"); next;};
  39.     while (<EPS>)
  40.     {
  41.     /^%[%\w]*BoundingBox/ && do
  42.     {
  43.         open(BB,">$eps.bb") || do
  44.         {
  45.         warn("$0: $eps.bb: $!\n");
  46.         next FILE;
  47.         };
  48.         print STDERR "Writing $eps.bb";
  49.         print BB;
  50.         close BB;
  51.         if (!$compressed)
  52.         {
  53.         print STDERR ", compressing $eps...";
  54.         system("$GZIP $eps") unless $compressed;
  55.         }
  56.         print STDERR "\n";
  57.         close EPS;
  58.         next FILE;
  59.     };
  60.     };
  61.     close EPS;
  62.     warn("$eps has no bounding box\n");
  63. }
  64.  
  65. # Local Variables:
  66. # mode: perl
  67. # auto-fill-hook: do-auto-fill
  68. # End:
  69.